package tedu.rocketmq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tedu.rocketmq.service.HelloService;

@Slf4j
@Component
// selectorExpression 标签选择器:"*" 当前是监听该主题下所有标签的消息
@RocketMQMessageListener(
        topic = "test-topic01",
        consumerGroup = "test-group03",
        selectorExpression = "*"
)
public class MyConsumer02 implements RocketMQListener<String> {

    @Autowired
    HelloService helloService;

    @Override
    public void onMessage(String message) {
        log.info("接收到的消息:{}",message);
        helloService.sayHi(message);
    }

}
